<template>
  <div>
    <div class="top">
      <el-button
        v-for="(item,index) in btnStr"
        :key="index"
        type="primary"
        round
        style="width: 120px;height: 36px;margin-right: 18px;font-size: 18px;"
        @click="clickFunction(index)"
      >{{ item }}
      </el-button>
      <el-input
        size="medium"
        placeholder="关键字搜索"
        suffix-icon="el-icon-search"
        style="width:200px;height: 36px;margin-left: 12px"
      >
      </el-input>
    </div>
    <div class="bottom">
      <el-table ref="table" :data="tableData" size="small" style="width: 100%;">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column prop="id" width="170" label="诊所编号"></el-table-column>
        <el-table-column prop="clinicName" width="159" label="诊所名称">
          <template slot-scope="scope">
            <a
              style="color: #719DC9;text-decoration:underline"
              @click="clinicDetail(scope.row)"
            >{{ scope.row.clinicName }}</a>
          </template>
        </el-table-column>
        <el-table-column prop="clinicType" width="159" label="诊所性质"></el-table-column>
        <el-table-column prop="salesId" width="159" label="所属销售"></el-table-column>
        <el-table-column prop="contacts" width="159" label="联系人"></el-table-column>
        <el-table-column prop="mobile" width="159" label="联系人电话"></el-table-column>
        <el-table-column prop="accManagerName" width="159" label="诊所负责人"></el-table-column>
        <el-table-column prop="doctorCount" width="159" label="医生数量"></el-table-column>
      </el-table>
    </div>
    <el-dialog
      class="addClinicDialog"
      :append-to-body="true"
      :title="btnStr[dialogIndex]"
      :visible.sync="addDialog"
      @close="dialogClose"
    >
      <!-- :width="dialogIndex === 0 || 1 ? '800px' : '600PX'" -->
      <addClinic
        v-if="dialogIndex === 0"
        ref="addClinic"
        :group-id="groupId"
      >
      </addClinic>
      <div class="flexRight">
        <div>
          <span slot="footer" class="dialog-footer">
            <el-button
              class="dialogBtn"
              round
              @click="closeDialog"
            >取消</el-button>
          </span>
          <span slot="footer" class="dialog-footer">
            <el-button
              type="primary"
              class="dialogBtn"
              round
              @click="dialogSure"
            >保存</el-button>
          </span>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { clinicQuery } from '@/api/oper';
import addClinic from './components/addClinic';

export default {
  name: 'OutpatientList',
  components: {
    addClinic
  },
  data() {
    return {
      btnStr: ['新增诊所', '编辑诊所', '移除诊所'],
      tableData: [],
      addDialog: false,
      dialogIndex: -1,
      groupId: ''
    };
  },
  created() {
    this.groupId = JSON.parse(this.$route.query.blocDetail).id;
    // 获取所属集团下所有诊所
    clinicQuery().then(res => {
      this.tableData = res.content;
    });
  },
  methods: {
    dialogSure() {
      switch (this.dialogIndex) {
        case 0:
          this.$refs.addClinic.addClinic();
      }
    },
    clickFunction(e) {
      this.dialogIndex = e;
      this.addDialog = true;
    },
    dialogClose() {
      this.dialogIndex = -1;
    },
    // 关闭弹窗
    closeDialog() {
      this.addDialog = false;
      this.dialogIndex = -1;
    },
    clinicDetail(row) {

    }
  }
};
</script>

<style lang='scss'>
  .addClinicDialog{
    .el-dialog__body{
      padding: 30px 60px;
    }
    .el-dialog{
      width: 1100px;

    }
  }
  .top {
    display: flex;
    margin: 30px 0px 20px 30px;
  }
  .flexRight {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
  .addDoctor {
    width: 80px;
    height: 24px;
    background: #D8E4F6;
    border: none;
    border-radius: 14px;
    font-size: 14px;
    color: #508FCC;
    outline: none;
    margin-left: -10px;
  }
</style>
